import 'package:flutter/material.dart';
//轮播图swiper第三方库
import 'package:flutter_swiper/flutter_swiper.dart';
//屏幕适配
import 'package:Smart/utils/screen_unit/gs_screen_util.dart';
import 'package:Smart/pages/productor008/studytest/res/swiper_list.dart';
import 'package:Smart/res/colors_res.dart';
import 'package:Smart/utils/routers/page_jump_service.dart';

class SwiperPage extends StatelessWidget {
  const SwiperPage({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
          leading: GestureDetector(
            onTap: () {
              PageJumpService.instance().goBack();
            },
            child: Icon(
              Icons.arrow_back_ios,
              size: 20,
              color: Color(0XFF231815),
            ),
          ),
          backgroundColor: ColorsRes.color_ffffff,
          title: Text(
            '轮播图',
            style: TextStyle(color: ColorsRes.color_000000),
            ),
        ),
      body: SwiperExample(),
    );
  }
}

class SwiperExample extends StatelessWidget {
  const SwiperExample({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 333.w,
      child: Swiper(
        //本地图片
        control: SwiperControl(),//左右控制按钮
        itemCount: swiperList.length, //图片循环数量
        itemBuilder: (BuildContext context, int index) {
          return Image.asset(swiperList[index]['url'],fit: BoxFit.cover,);
        },
        //图片下面的小圆点
        pagination: SwiperPagination(),
        autoplay: true,
      ),
    );
  }
}
